<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>了解数据代理</title>
        <script type="text/javascript" src="../../js/vue.js"></script>
    </head>
    <body>
       <div></div>

        <script type="text/javascript">
            
            let obj = {x:100}
            let obj2 = {y:200}
            //给obj2添加x属性，值为obj的x属性值，修改obj2的属性值，会修改obj的x属性值
            Object.defineProperty(obj2,'x',{
                get(){
                    return obj.x
                },
                set(value){
                    obj.x = value
                }
            })
           
        </script>

        
    </body>
</html>